<style type="text/css">
    .layui-form-label {
        width: 200px;
    }


</style>
<div class="layui-card">
    <div class="layui-card-header">
        <h2 class="header-title">会员等级配置</h2>
    </div>
    <div class="layui-card-body">
        <form id="query-form" class="layui-form" lay-filter="query-form">
            <input type="hidden" name="id"/>
            <input type="hidden" name="grade1" value="0"/>
            <div class="layui-form-item">
                <label class="layui-form-label "></label>
                <div class="layui-input-inline">
                    <input type="text" name="grade1Name" class="layui-input" lay-verify="required"/>
                </div>
                <div class="layui-form-mid mid-block">0</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label "></label>
                <div class="layui-input-inline">
                    <input type="text" name="grade2Name" class="layui-input" lay-verify="required"/>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="grade2" class="layui-input" lay-verify="required|frac"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label "></label>
                <div class="layui-input-inline">
                    <input type="text" name="grade3Name" class="layui-input" lay-verify="required"/>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="grade3" class="layui-input" lay-verify="required|frac"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label "></label>
                <div class="layui-input-inline">
                    <input type="text" name="grade4Name" class="layui-input" lay-verify="required"/>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="grade4" class="layui-input" lay-verify="required|frac"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label "></label>
                <div class="layui-input-inline">
                    <input type="text" name="grade5Name" class="layui-input" lay-verify="required"/>
                </div>
                <div class="layui-input-inline">
                    <input type="number" name="grade5" class="layui-input" lay-verify="required|frac"/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label "></label>
                <div class="layui-input-inline" style="width:400px">
                    <div class="layui-form-mid mid-block">
                        会员经验值：会员通过购物等途径获取经验值，根据会员的经验值设定会员的等级。如铜牌会员经验值设定为500，则当会员的经验值满500后，等级从注册会员提升为铜牌会员
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label " ></label>
                <div class="layui-input-inline" >
                    <button class="layui-btn" type="button" lay-filter="doSub" lay-submit="">提交</button>
                </div>
            </div>
        </form>
    </div>

</div>

<script type="text/javascript">
    layui.use(['tools', 'setter', 'form', 'admin', 'layer'], function () {
        const tools = layui.tools;
        const config = layui.setter;
        const form = layui.form;
        const layer = layui.layer;
        const $ = layui.$;
        methods = {
            init: function () {
                layer.load();
                tools.getJSON({
                    url: "/mall/api/seller/member/getSellerGrade"
                }).done(function (res) {
                    layer.closeAll("loading");
                    if (0 == res.code) {
                        var data = res.data;
                        form.val("query-form", {
                            id: data.id,
                            grade5: data.grade5,
                            grade5Name: data.grade5Name,
                            grade4: data.grade4,
                            grade4Name: data.grade4Name,
                            grade3: data.grade3,
                            grade3Name: data.grade3Name,
                            grade2: data.grade2,
                            grade2Name: data.grade2Name,
                            grade1Name: data.grade1Name
                        })
                    } else {
                        layer.msg(res.msg)
                    }
                })
                form.on('submit(doSub)', function (data) {
                    tools.postJSON({
                        url: "/mall/sv/seller/member/updateSellerGrade",
                        params: data.field
                    }).done(function (res) {
                        layer.msg(res.msg)
                    })
                    return false;
                });
            }
        };
        methods.init();
        form.verify({
            frac: function (value, item) { //value：表单的值、item：表单的DOM对象
                var reg = /^\+?[0-9]\d*$/;
                if (!reg.test(value)) {
                    return "只能输入大于等于0的正整数"
                }

            }
        });
    });
</script>